//
//  OrderModel.m
//  Courses
//
//  Created by YiXuePxh on 15/4/7.
//  Copyright (c) 2015年 boyibang. All rights reserved.
//

#import "OrderModel.h"

@implementation OrderModel

-(id)initWithJson:(id)jsonArray{
//    _course = [[PublicCourse alloc]initWithJsonDict:jsonArray];
    self.orderId = jsonArray[@"orderId"];
    self.orderNo = jsonArray[@"orderNo"];
    self.orderTime = jsonArray[@"orderTime"];
    self.orderStatus = jsonArray[@"orderStatus"];
    self.courseId = jsonArray[@"courseId"];
    self.courseName = jsonArray[@"courseName"];
    self.classId = jsonArray[@"classId"];
    self.className = jsonArray[@"className"];
    self.classOpenDate = jsonArray[@"classOpenDate"];
    self.realAmount = jsonArray[@"realAmount"];
    self.teacherId = jsonArray[@"teacherId"];
    self.teacherName = jsonArray[@"teacherName"];
    self.teacherHeadPhotoUrl = jsonArray[@"teacherHeadPhotoUrl"];
    return self;
}
+(NSArray* )getCourses{
    NSMutableArray* courses = [[NSMutableArray alloc] init];
    Request* request = [Request requestWithName:@"get_orders"];
    Response* response = [request response];
    if (response.result) {
        if ([response.content[@"orders"] isKindOfClass:[NSArray class]]) {
            for (id jsonArray in response.content[@"orders"]) {
                OrderModel* order = [[OrderModel alloc]initWithJson:jsonArray];
                [courses addObject:order];
            }
        }
    }
    return [courses copy];
}

@end
